package com.yz.alipay.pay.config;

import com.alipay.api.AlipayClient;
import com.alipay.api.DefaultAlipayClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 描述：
 **/
@Configuration
@ConfigurationProperties(prefix = "alipay")
public class AlipayConfig {


   private String address;
   private String appId;
   private String appPrivateKey;
   private String alipayPublicKey;
    @Bean
    public AlipayClient getAlipayClient(){
        System.out.println(address);
        System.out.println(appId);
        System.out.println(appPrivateKey);
        System.out.println(alipayPublicKey);
        return new DefaultAlipayClient(address,
                appId,
                appPrivateKey,
                "json", "utf-8", alipayPublicKey, "RSA2");
    }

    @Override
    public String toString() {
        return "AlipayConfig{" +
                "address='" + address + '\'' +
                ", appId='" + appId + '\'' +
                ", appPrivateKey='" + appPrivateKey + '\'' +
                ", alipayPublicKey='" + alipayPublicKey + '\'' +
                '}';
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getAppId() {
        return appId;
    }

    public void setAppId(String appId) {
        this.appId = appId;
    }

    public String getAppPrivateKey() {
        return appPrivateKey;
    }

    public void setAppPrivateKey(String appPrivateKey) {
        this.appPrivateKey = appPrivateKey;
    }

    public String getAlipayPublicKey() {
        return alipayPublicKey;
    }

    public void setAlipayPublicKey(String alipayPublicKey) {
        this.alipayPublicKey = alipayPublicKey;
    }
}
